-
-
Notifications
You must be signed in to change notification settings - Fork 737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display prompt for enabling GPS #252
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some comments.
{ | ||
final AlertDialog.Builder builder = new AlertDialog.Builder(activity); | ||
final String action = Settings.ACTION_LOCATION_SOURCE_SETTINGS; | ||
final String message = "Enable location service to find current location. Click OK to go to."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use hardcoded strings.
@@ -230,6 +233,25 @@ private void initPreferences() { | |||
findPreference(KEY_DEVICE).setSummary(sharedPreferences.getString(KEY_DEVICE, null)); | |||
} | |||
|
|||
private void displayPromptForEnablingGPS( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GPS should be camel-cased.
final Activity activity) | ||
{ | ||
final AlertDialog.Builder builder = new AlertDialog.Builder(activity); | ||
final String action = Settings.ACTION_LOCATION_SOURCE_SETTINGS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need a variable for this?
@@ -255,6 +277,10 @@ private void startTrackingService(boolean checkPermission, boolean permission) { | |||
startService(new Intent(this, TrackingService.class)); | |||
alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, | |||
15000, 15000, alarmIntent); | |||
String locationProviders = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); | |||
if (locationProviders == null || locationProviders.equals("")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use TextUtils.isEmpty(...)
instead.
@@ -255,6 +277,10 @@ private void startTrackingService(boolean checkPermission, boolean permission) { | |||
startService(new Intent(this, TrackingService.class)); | |||
alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, | |||
15000, 15000, alarmIntent); | |||
String locationProviders = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); | |||
if (locationProviders == null || locationProviders.equals("")) { | |||
displayPromptForEnablingGPS(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it called "GPS" when you check for all providers?
@@ -255,6 +277,10 @@ private void startTrackingService(boolean checkPermission, boolean permission) { | |||
startService(new Intent(this, TrackingService.class)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we wait till user enables providers before starting the service?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, because if user not enable providers, it will be useless. Traccar-client cannot update location and send it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You said yes, but you haven't fixed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, I'm still trying but have not been successful. I try to use AsyncTask (https://developer.android.com/reference/android/os/AsyncTask.html)
…gs, use TextUtils to check Location
{ | ||
final AlertDialog.Builder builder = new AlertDialog.Builder(activity); | ||
builder.setMessage(R.string.prompt_location_service) | ||
.setPositiveButton("OK", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still hardcoded string here.
@@ -44,4 +44,5 @@ | |||
<string name="status_connectivity_change">Connectivity change</string> | |||
<string name="hidden_app_name">Device Settings</string> | |||
<string name="hidden_alert">The app has been hidden. To open it again please dial 8722227 (TRACCAR).</string> | |||
<string name="prompt_location_service">Enable location service to find current location. Click OK to go to.</string> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use some better wording. Something like:
Please enable location services. Click OK to open settings screen.
@@ -255,6 +277,10 @@ private void startTrackingService(boolean checkPermission, boolean permission) { | |||
startService(new Intent(this, TrackingService.class)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You said yes, but you haven't fixed it.
😁 |
Are the code conflicts resolved already? Is this feature ready for releasing? |
As you can see, there were no commits after my review, so nothing is solved. |
Display prompt for enabling GPS, when it disable. Because when forget to enable Location service, Traccar client cannot send location at all.